//
//  ParkingNumCell.m
//  PropertyMananger
//
//  Created by bh on 17/1/5.
//  Copyright © 2017年 BH. All rights reserved.
//

#import "ParkingQueryCell.h"

@implementation ParkingQueryCell
- (instancetype)initWithFrame:(CGRect)frame
{
    
    self = [super initWithFrame:frame];
    if (self) {
        
        
        if (self.queryType == ParkingNumQuery) {
            
            UIView * bgView = [[UIView alloc]init];
            [self.contentView addSubview:bgView];
            
            [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
                
                make.leading.equalTo(self).with.offset(0);
                make.top.equalTo(self).with.offset(0);
                make.size.mas_equalTo(CGSizeMake(60, 100));
            }];
            
            self.parkingImg = [[UIImageView alloc]init];
            [bgView addSubview:self.parkingImg];

            
            self.numLabel = [[UILabel alloc]init];
            [bgView addSubview:self.numLabel];
            //  self.infoTitleLabel.backgroundColor = BHRandColor;
            
            self.numLabel.textColor = BHColor(51, 51, 51);
            self.numLabel.textAlignment = NSTextAlignmentCenter;
            self.numLabel.font = BHFont(15);
            
            [self.numLabel  mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.parkingImg.mas_bottom).with.offset(10);
                make.centerX.equalTo(self.parkingImg).with.offset(0);
                make.size.mas_equalTo(CGSizeMake(100 , 25));
            }];
            
            
        }else if (self.queryType == CarNumQuery)
        {
            UIView * bgView = [[UIView alloc]init];
            [self.contentView addSubview:bgView];
            
            [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
                
                make.leading.equalTo(self).with.offset(0);
                make.top.equalTo(self).with.offset(0);
                make.size.mas_equalTo(CGSizeMake(60, 100));
            }];
            
            self.parkingImg = [[UIImageView alloc]init];
            [bgView addSubview:self.parkingImg];

            
            self.numLabel = [[UILabel alloc]init];
            [bgView addSubview:self.numLabel];
            //  self.infoTitleLabel.backgroundColor = BHRandColor;
            
            self.numLabel.textColor = BHColor(51, 51, 51);
            self.numLabel.textAlignment = NSTextAlignmentCenter;
            self.numLabel.font = BHFont(15);
            
            [self.numLabel  mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.parkingImg.mas_bottom).with.offset(10);
                make.centerX.equalTo(self.parkingImg).with.offset(0);
                make.size.mas_equalTo(CGSizeMake(100 , 25));
            }];
            
            
        }
        
    }
    return self;
}

-(void)setQueryType:(QueryType)queryType{
    _queryType = queryType;
    
    if(queryType == ParkingNumQuery){
        
        self.parkingImg.image = IMG(@"ico_parking_lot_query");
        
       [self.parkingImg mas_updateConstraints:^(MASConstraintMaker *make) {
           make.leading.equalTo(self).with.offset(10);
           make.top.equalTo(self).with.offset(10);
           make.size.mas_equalTo(CGSizeMake(40, 60));
       }];
        
        
    }else if(queryType == CarNumQuery){
        
        self.parkingImg.image = IMG(@"ico_license_plate_query");
        [self.parkingImg mas_updateConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self).with.offset(10);
            make.top.equalTo(self).with.offset(10);
            make.size.mas_equalTo(CGSizeMake(50, 30));
        }];
 
        
    }
    
}
@end
